using TouchSocket.Core;

namespace DmServer.Core.Helper;

public class CryptoHelper
{
    private readonly static string encryptKey = "D2f.5#_8";

    /// <summary>
    /// 解密
    /// </summary>
    /// <param name="byteBlock"></param>
    /// <returns></returns>
    public static string DecryptDES(byte[] byteBlock)
    {
        var result = Encoding.UTF8.GetString(DataSecurity.DecryptDES(byteBlock, encryptKey));
        return result;
    }

    /// <summary>
    /// 解密
    /// </summary>
    /// <param name="byteBlock"></param>
    /// <returns></returns>
    public static byte[] DecryptDESToByteArr(byte[] bytes)
    {
        var result = DataSecurity.DecryptDES(bytes, encryptKey);
        return result;
    }

    /// <summary>
    /// 加密
    /// </summary>
    /// <param name="message"></param>
    /// <returns></returns>
    public static byte[] EncryptDES(string message)
    {
        var result = DataSecurity.EncryptDES(Encoding.UTF8.GetBytes(message), encryptKey);
        return result;
    }
    /// <summary>
    /// 加密
    /// </summary>
    /// <param name="message"></param>
    /// <returns></returns>
    public static byte[] EncryptDES(byte[] bytes)
    {
        var result = DataSecurity.EncryptDES(bytes, encryptKey);
        return result;
    }
}
